package com.gy.bearhelps.setting.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gy.bearhelps.R;

/**
 * 作者：gy on 16/11/5
 * 说明：
 */
public class FontAdapter extends BaseAdapter {

    private Context context;
    private String[] strs;
    private int select = 4;

    public FontAdapter(Context context,String[] strs){
        this.context = context;
        this.strs = strs;
    }

    public void setSelect(int select){
        this.select = select;
    }

    @Override
    public int getCount() {
        return 6;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if(view == null){
            view = View.inflate(context, R.layout.adapter_font,null);
            holder = new ViewHolder();
            holder.tvFont = (TextView) view.findViewById(R.id.adapter_font_tv);
            holder.img = (ImageView) view.findViewById(R.id.adapter_font_img);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tvFont.setText(strs[position]);
        if(position == select){
            holder.img.setVisibility(View.VISIBLE);
        } else {
            holder.img.setVisibility(View.GONE);
        }
        return view;
    }

    class ViewHolder{
        TextView tvFont;
        ImageView img;
    }
}
